#include"common.hpp"
#include"protocol.hpp"

class CalNet{
public:
    Respond Calculator(Request& req)
    {
        int x = req.GetX();
        int y = req.GetY();
        char oper = req.GetOper();
        //LOG(level::DEBUG)<<"oper: "<<oper;
        int result = 0;
        std::string code = "false";

        switch (oper)
        {
        case '+':
            result = x + y;
            code = "true";
            return Respond(result,code);
        case '-':
            result = x - y;
            code = "true";
            return Respond(result,code);
        case '*':
            result = x * y;
            code = "true";
            return Respond(result,code);
        case '/':
            if (y == 0)
                return Respond(result,code); 
            result = x / y;
            code = "true";
            return Respond(result,code);
        default:
            return Respond(result,"NO KNOW");
        }
        
    }

};